(0) Obligation:

Clauses:

hbal_tree(zero, nil).
hbal_tree(s(zero), t(x, nil, nil)).
hbal_tree(s(s(X)), t(x, L, R)) :- ','(distr(s(X), X, DL, DR), ','(hbal_tree(DL, L), hbal_tree(DR, R))).
distr(D1, X1, D1, D1).
distr(D1, D2, D1, D2).
distr(D1, D2, D2, D1).

Query: hbal_tree(g,a)

(1) PrologToDTProblemTransformerProof (SOUND transformation)

Built DT problem from termination graph DT10.

(2) Obligation:

Triples:

hbal_treeA(s(s(X1)), t(x, X2, X3)) :- hbal_treeA(s(X1), X2).
hbal_treeA(s(s(X1)), t(x, X2, X3)) :- ','(hbal_treecA(s(X1), X2), hbal_treeA(s(X1), X3)).
hbal_treeA(s(s(X1)), t(x, X2, X3)) :- hbal_treeA(s(X1), X2).
hbal_treeA(s(s(X1)), t(x, X2, X3)) :- ','(hbal_treecA(s(X1), X2), hbal_treeA(X1, X3)).
hbal_treeA(s(s(X1)), t(x, X2, X3)) :- hbal_treeA(X1, X2).
hbal_treeA(s(s(X1)), t(x, X2, X3)) :- ','(hbal_treecA(X1, X2), hbal_treeA(s(X1), X3)).

Clauses:

hbal_treecA(zero, nil).
hbal_treecA(s(zero), t(x, nil, nil)).
hbal_treecA(s(s(X1)), t(x, X2, X3)) :- ','(hbal_treecA(s(X1), X2), hbal_treecA(s(X1), X3)).
hbal_treecA(s(s(X1)), t(x, X2, X3)) :- ','(hbal_treecA(s(X1), X2), hbal_treecA(X1, X3)).
hbal_treecA(s(s(X1)), t(x, X2, X3)) :- ','(hbal_treecA(X1, X2), hbal_treecA(s(X1), X3)).

Afs:

hbal_treeA(x1, x2)  =  hbal_treeA(x1)

(3) TriplesToPiDPProof (SOUND transformation)

We use the technique of [DT09]. With regard to the inferred argument filtering the predicates were used in the following modes:
hbal_treeA_in: (b,f)
hbal_treecA_in: (b,f)
Transforming TRIPLES into the following Term Rewriting System:
Pi DP problem:
The TRS P consists of the following rules:

HBAL_TREEA_IN_GA(s(s(X1)), t(x, X2, X3)) → U1_GA(X1, X2, X3, hbal_treeA_in_ga(s(X1), X2))
HBAL_TREEA_IN_GA(s(s(X1)), t(x, X2, X3)) → HBAL_TREEA_IN_GA(s(X1), X2)
HBAL_TREEA_IN_GA(s(s(X1)), t(x, X2, X3)) → U2_GA(X1, X2, X3, hbal_treecA_in_ga(s(X1), X2))
U2_GA(X1, X2, X3, hbal_treecA_out_ga(s(X1), X2)) → U3_GA(X1, X2, X3, hbal_treeA_in_ga(s(X1), X3))
U2_GA(X1, X2, X3, hbal_treecA_out_ga(s(X1), X2)) → HBAL_TREEA_IN_GA(s(X1), X3)
HBAL_TREEA_IN_GA(s(s(X1)), t(x, X2, X3)) → U5_GA(X1, X2, X3, hbal_treeA_in_ga(X1, X2))
HBAL_TREEA_IN_GA(s(s(X1)), t(x, X2, X3)) → HBAL_TREEA_IN_GA(X1, X2)
HBAL_TREEA_IN_GA(s(s(X1)), t(x, X2, X3)) → U6_GA(X1, X2, X3, hbal_treecA_in_ga(X1, X2))
U6_GA(X1, X2, X3, hbal_treecA_out_ga(X1, X2)) → U7_GA(X1, X2, X3, hbal_treeA_in_ga(s(X1), X3))
U6_GA(X1, X2, X3, hbal_treecA_out_ga(X1, X2)) → HBAL_TREEA_IN_GA(s(X1), X3)
U2_GA(X1, X2, X3, hbal_treecA_out_ga(s(X1), X2)) → U4_GA(X1, X2, X3, hbal_treeA_in_ga(X1, X3))
U2_GA(X1, X2, X3, hbal_treecA_out_ga(s(X1), X2)) → HBAL_TREEA_IN_GA(X1, X3)

The TRS R consists of the following rules:

hbal_treecA_in_ga(zero, nil) → hbal_treecA_out_ga(zero, nil)
hbal_treecA_in_ga(s(zero), t(x, nil, nil)) → hbal_treecA_out_ga(s(zero), t(x, nil, nil))
hbal_treecA_in_ga(s(s(X1)), t(x, X2, X3)) → U9_ga(X1, X2, X3, hbal_treecA_in_ga(s(X1), X2))
hbal_treecA_in_ga(s(s(X1)), t(x, X2, X3)) → U12_ga(X1, X2, X3, hbal_treecA_in_ga(X1, X2))
U12_ga(X1, X2, X3, hbal_treecA_out_ga(X1, X2)) → U13_ga(X1, X2, X3, hbal_treecA_in_ga(s(X1), X3))
U13_ga(X1, X2, X3, hbal_treecA_out_ga(s(X1), X3)) → hbal_treecA_out_ga(s(s(X1)), t(x, X2, X3))
U9_ga(X1, X2, X3, hbal_treecA_out_ga(s(X1), X2)) → U10_ga(X1, X2, X3, hbal_treecA_in_ga(s(X1), X3))
U10_ga(X1, X2, X3, hbal_treecA_out_ga(s(X1), X3)) → hbal_treecA_out_ga(s(s(X1)), t(x, X2, X3))
U9_ga(X1, X2, X3, hbal_treecA_out_ga(s(X1), X2)) → U11_ga(X1, X2, X3, hbal_treecA_in_ga(X1, X3))
U11_ga(X1, X2, X3, hbal_treecA_out_ga(X1, X3)) → hbal_treecA_out_ga(s(s(X1)), t(x, X2, X3))

The argument filtering Pi contains the following mapping:
hbal_treeA_in_ga(x1, x2)  =  hbal_treeA_in_ga(x1)
s(x1)  =  s(x1)
hbal_treecA_in_ga(x1, x2)  =  hbal_treecA_in_ga(x1)
zero  =  zero
hbal_treecA_out_ga(x1, x2)  =  hbal_treecA_out_ga(x1, x2)
U9_ga(x1, x2, x3, x4)  =  U9_ga(x1, x4)
U12_ga(x1, x2, x3, x4)  =  U12_ga(x1, x4)
U13_ga(x1, x2, x3, x4)  =  U13_ga(x1, x2, x4)
U10_ga(x1, x2, x3, x4)  =  U10_ga(x1, x2, x4)
U11_ga(x1, x2, x3, x4)  =  U11_ga(x1, x2, x4)
t(x1, x2, x3)  =  t(x1, x2, x3)
x  =  x
HBAL_TREEA_IN_GA(x1, x2)  =  HBAL_TREEA_IN_GA(x1)
U1_GA(x1, x2, x3, x4)  =  U1_GA(x1, x4)
U2_GA(x1, x2, x3, x4)  =  U2_GA(x1, x4)
U3_GA(x1, x2, x3, x4)  =  U3_GA(x1, x4)
U5_GA(x1, x2, x3, x4)  =  U5_GA(x1, x4)
U6_GA(x1, x2, x3, x4)  =  U6_GA(x1, x4)
U7_GA(x1, x2, x3, x4)  =  U7_GA(x1, x4)
U4_GA(x1, x2, x3, x4)  =  U4_GA(x1, x4)

We have to consider all (P,R,Pi)-chains

Infinitary Constructor Rewriting Termination of PiDP implies Termination of TRIPLES

(4) Obligation:

Pi DP problem:
The TRS P consists of the following rules:

HBAL_TREEA_IN_GA(s(s(X1)), t(x, X2, X3)) → U1_GA(X1, X2, X3, hbal_treeA_in_ga(s(X1), X2))
HBAL_TREEA_IN_GA(s(s(X1)), t(x, X2, X3)) → HBAL_TREEA_IN_GA(s(X1), X2)
HBAL_TREEA_IN_GA(s(s(X1)), t(x, X2, X3)) → U2_GA(X1, X2, X3, hbal_treecA_in_ga(s(X1), X2))
U2_GA(X1, X2, X3, hbal_treecA_out_ga(s(X1), X2)) → U3_GA(X1, X2, X3, hbal_treeA_in_ga(s(X1), X3))
U2_GA(X1, X2, X3, hbal_treecA_out_ga(s(X1), X2)) → HBAL_TREEA_IN_GA(s(X1), X3)
HBAL_TREEA_IN_GA(s(s(X1)), t(x, X2, X3)) → U5_GA(X1, X2, X3, hbal_treeA_in_ga(X1, X2))
HBAL_TREEA_IN_GA(s(s(X1)), t(x, X2, X3)) → HBAL_TREEA_IN_GA(X1, X2)
HBAL_TREEA_IN_GA(s(s(X1)), t(x, X2, X3)) → U6_GA(X1, X2, X3, hbal_treecA_in_ga(X1, X2))
U6_GA(X1, X2, X3, hbal_treecA_out_ga(X1, X2)) → U7_GA(X1, X2, X3, hbal_treeA_in_ga(s(X1), X3))
U6_GA(X1, X2, X3, hbal_treecA_out_ga(X1, X2)) → HBAL_TREEA_IN_GA(s(X1), X3)
U2_GA(X1, X2, X3, hbal_treecA_out_ga(s(X1), X2)) → U4_GA(X1, X2, X3, hbal_treeA_in_ga(X1, X3))
U2_GA(X1, X2, X3, hbal_treecA_out_ga(s(X1), X2)) → HBAL_TREEA_IN_GA(X1, X3)

The TRS R consists of the following rules:

hbal_treecA_in_ga(zero, nil) → hbal_treecA_out_ga(zero, nil)
hbal_treecA_in_ga(s(zero), t(x, nil, nil)) → hbal_treecA_out_ga(s(zero), t(x, nil, nil))
hbal_treecA_in_ga(s(s(X1)), t(x, X2, X3)) → U9_ga(X1, X2, X3, hbal_treecA_in_ga(s(X1), X2))
hbal_treecA_in_ga(s(s(X1)), t(x, X2, X3)) → U12_ga(X1, X2, X3, hbal_treecA_in_ga(X1, X2))
U12_ga(X1, X2, X3, hbal_treecA_out_ga(X1, X2)) → U13_ga(X1, X2, X3, hbal_treecA_in_ga(s(X1), X3))
U13_ga(X1, X2, X3, hbal_treecA_out_ga(s(X1), X3)) → hbal_treecA_out_ga(s(s(X1)), t(x, X2, X3))
U9_ga(X1, X2, X3, hbal_treecA_out_ga(s(X1), X2)) → U10_ga(X1, X2, X3, hbal_treecA_in_ga(s(X1), X3))
U10_ga(X1, X2, X3, hbal_treecA_out_ga(s(X1), X3)) → hbal_treecA_out_ga(s(s(X1)), t(x, X2, X3))
U9_ga(X1, X2, X3, hbal_treecA_out_ga(s(X1), X2)) → U11_ga(X1, X2, X3, hbal_treecA_in_ga(X1, X3))
U11_ga(X1, X2, X3, hbal_treecA_out_ga(X1, X3)) → hbal_treecA_out_ga(s(s(X1)), t(x, X2, X3))

The argument filtering Pi contains the following mapping:
hbal_treeA_in_ga(x1, x2)  =  hbal_treeA_in_ga(x1)
s(x1)  =  s(x1)
hbal_treecA_in_ga(x1, x2)  =  hbal_treecA_in_ga(x1)
zero  =  zero
hbal_treecA_out_ga(x1, x2)  =  hbal_treecA_out_ga(x1, x2)
U9_ga(x1, x2, x3, x4)  =  U9_ga(x1, x4)
U12_ga(x1, x2, x3, x4)  =  U12_ga(x1, x4)
U13_ga(x1, x2, x3, x4)  =  U13_ga(x1, x2, x4)
U10_ga(x1, x2, x3, x4)  =  U10_ga(x1, x2, x4)
U11_ga(x1, x2, x3, x4)  =  U11_ga(x1, x2, x4)
t(x1, x2, x3)  =  t(x1, x2, x3)
x  =  x
HBAL_TREEA_IN_GA(x1, x2)  =  HBAL_TREEA_IN_GA(x1)
U1_GA(x1, x2, x3, x4)  =  U1_GA(x1, x4)
U2_GA(x1, x2, x3, x4)  =  U2_GA(x1, x4)
U3_GA(x1, x2, x3, x4)  =  U3_GA(x1, x4)
U5_GA(x1, x2, x3, x4)  =  U5_GA(x1, x4)
U6_GA(x1, x2, x3, x4)  =  U6_GA(x1, x4)
U7_GA(x1, x2, x3, x4)  =  U7_GA(x1, x4)
U4_GA(x1, x2, x3, x4)  =  U4_GA(x1, x4)

We have to consider all (P,R,Pi)-chains

(5) DependencyGraphProof (EQUIVALENT transformation)

The approximation of the Dependency Graph [LOPSTR] contains 1 SCC with 5 less nodes.

(6) Obligation:

Pi DP problem:
The TRS P consists of the following rules:

HBAL_TREEA_IN_GA(s(s(X1)), t(x, X2, X3)) → U2_GA(X1, X2, X3, hbal_treecA_in_ga(s(X1), X2))
U2_GA(X1, X2, X3, hbal_treecA_out_ga(s(X1), X2)) → HBAL_TREEA_IN_GA(s(X1), X3)
HBAL_TREEA_IN_GA(s(s(X1)), t(x, X2, X3)) → HBAL_TREEA_IN_GA(s(X1), X2)
HBAL_TREEA_IN_GA(s(s(X1)), t(x, X2, X3)) → HBAL_TREEA_IN_GA(X1, X2)
HBAL_TREEA_IN_GA(s(s(X1)), t(x, X2, X3)) → U6_GA(X1, X2, X3, hbal_treecA_in_ga(X1, X2))
U6_GA(X1, X2, X3, hbal_treecA_out_ga(X1, X2)) → HBAL_TREEA_IN_GA(s(X1), X3)
U2_GA(X1, X2, X3, hbal_treecA_out_ga(s(X1), X2)) → HBAL_TREEA_IN_GA(X1, X3)

The TRS R consists of the following rules:

hbal_treecA_in_ga(zero, nil) → hbal_treecA_out_ga(zero, nil)
hbal_treecA_in_ga(s(zero), t(x, nil, nil)) → hbal_treecA_out_ga(s(zero), t(x, nil, nil))
hbal_treecA_in_ga(s(s(X1)), t(x, X2, X3)) → U9_ga(X1, X2, X3, hbal_treecA_in_ga(s(X1), X2))
hbal_treecA_in_ga(s(s(X1)), t(x, X2, X3)) → U12_ga(X1, X2, X3, hbal_treecA_in_ga(X1, X2))
U12_ga(X1, X2, X3, hbal_treecA_out_ga(X1, X2)) → U13_ga(X1, X2, X3, hbal_treecA_in_ga(s(X1), X3))
U13_ga(X1, X2, X3, hbal_treecA_out_ga(s(X1), X3)) → hbal_treecA_out_ga(s(s(X1)), t(x, X2, X3))
U9_ga(X1, X2, X3, hbal_treecA_out_ga(s(X1), X2)) → U10_ga(X1, X2, X3, hbal_treecA_in_ga(s(X1), X3))
U10_ga(X1, X2, X3, hbal_treecA_out_ga(s(X1), X3)) → hbal_treecA_out_ga(s(s(X1)), t(x, X2, X3))
U9_ga(X1, X2, X3, hbal_treecA_out_ga(s(X1), X2)) → U11_ga(X1, X2, X3, hbal_treecA_in_ga(X1, X3))
U11_ga(X1, X2, X3, hbal_treecA_out_ga(X1, X3)) → hbal_treecA_out_ga(s(s(X1)), t(x, X2, X3))

The argument filtering Pi contains the following mapping:
s(x1)  =  s(x1)
hbal_treecA_in_ga(x1, x2)  =  hbal_treecA_in_ga(x1)
zero  =  zero
hbal_treecA_out_ga(x1, x2)  =  hbal_treecA_out_ga(x1, x2)
U9_ga(x1, x2, x3, x4)  =  U9_ga(x1, x4)
U12_ga(x1, x2, x3, x4)  =  U12_ga(x1, x4)
U13_ga(x1, x2, x3, x4)  =  U13_ga(x1, x2, x4)
U10_ga(x1, x2, x3, x4)  =  U10_ga(x1, x2, x4)
U11_ga(x1, x2, x3, x4)  =  U11_ga(x1, x2, x4)
t(x1, x2, x3)  =  t(x1, x2, x3)
x  =  x
HBAL_TREEA_IN_GA(x1, x2)  =  HBAL_TREEA_IN_GA(x1)
U2_GA(x1, x2, x3, x4)  =  U2_GA(x1, x4)
U6_GA(x1, x2, x3, x4)  =  U6_GA(x1, x4)

We have to consider all (P,R,Pi)-chains

(7) PiDPToQDPProof (SOUND transformation)

Transforming (infinitary) constructor rewriting Pi-DP problem [LOPSTR] into ordinary QDP problem [LPAR04] by application of Pi.

(8) Obligation:

Q DP problem:
The TRS P consists of the following rules:

HBAL_TREEA_IN_GA(s(s(X1))) → U2_GA(X1, hbal_treecA_in_ga(s(X1)))
U2_GA(X1, hbal_treecA_out_ga(s(X1), X2)) → HBAL_TREEA_IN_GA(s(X1))
HBAL_TREEA_IN_GA(s(s(X1))) → HBAL_TREEA_IN_GA(s(X1))
HBAL_TREEA_IN_GA(s(s(X1))) → HBAL_TREEA_IN_GA(X1)
HBAL_TREEA_IN_GA(s(s(X1))) → U6_GA(X1, hbal_treecA_in_ga(X1))
U6_GA(X1, hbal_treecA_out_ga(X1, X2)) → HBAL_TREEA_IN_GA(s(X1))
U2_GA(X1, hbal_treecA_out_ga(s(X1), X2)) → HBAL_TREEA_IN_GA(X1)

The TRS R consists of the following rules:

hbal_treecA_in_ga(zero) → hbal_treecA_out_ga(zero, nil)
hbal_treecA_in_ga(s(zero)) → hbal_treecA_out_ga(s(zero), t(x, nil, nil))
hbal_treecA_in_ga(s(s(X1))) → U9_ga(X1, hbal_treecA_in_ga(s(X1)))
hbal_treecA_in_ga(s(s(X1))) → U12_ga(X1, hbal_treecA_in_ga(X1))
U12_ga(X1, hbal_treecA_out_ga(X1, X2)) → U13_ga(X1, X2, hbal_treecA_in_ga(s(X1)))
U13_ga(X1, X2, hbal_treecA_out_ga(s(X1), X3)) → hbal_treecA_out_ga(s(s(X1)), t(x, X2, X3))
U9_ga(X1, hbal_treecA_out_ga(s(X1), X2)) → U10_ga(X1, X2, hbal_treecA_in_ga(s(X1)))
U10_ga(X1, X2, hbal_treecA_out_ga(s(X1), X3)) → hbal_treecA_out_ga(s(s(X1)), t(x, X2, X3))
U9_ga(X1, hbal_treecA_out_ga(s(X1), X2)) → U11_ga(X1, X2, hbal_treecA_in_ga(X1))
U11_ga(X1, X2, hbal_treecA_out_ga(X1, X3)) → hbal_treecA_out_ga(s(s(X1)), t(x, X2, X3))

The set Q consists of the following terms:

hbal_treecA_in_ga(x0)
U12_ga(x0, x1)
U13_ga(x0, x1, x2)
U9_ga(x0, x1)
U10_ga(x0, x1, x2)
U11_ga(x0, x1, x2)

We have to consider all (P,Q,R)-chains.

(9) MRRProof (EQUIVALENT transformation)

By using the rule removal processor [LPAR04] with the following ordering, at least one Dependency Pair or term rewrite system rule of this QDP problem can be strictly oriented.
Strictly oriented dependency pairs:

HBAL_TREEA_IN_GA(s(s(X1))) → U2_GA(X1, hbal_treecA_in_ga(s(X1)))
U2_GA(X1, hbal_treecA_out_ga(s(X1), X2)) → HBAL_TREEA_IN_GA(s(X1))
HBAL_TREEA_IN_GA(s(s(X1))) → HBAL_TREEA_IN_GA(s(X1))
HBAL_TREEA_IN_GA(s(s(X1))) → HBAL_TREEA_IN_GA(X1)
HBAL_TREEA_IN_GA(s(s(X1))) → U6_GA(X1, hbal_treecA_in_ga(X1))
U6_GA(X1, hbal_treecA_out_ga(X1, X2)) → HBAL_TREEA_IN_GA(s(X1))
U2_GA(X1, hbal_treecA_out_ga(s(X1), X2)) → HBAL_TREEA_IN_GA(X1)


Used ordering: Polynomial interpretation [POLO]:

POL(HBAL_TREEA_IN_GA(x1)) = 1 + 2·x1   
POL(U10_ga(x1, x2, x3)) = 2 + 2·x1 + 2·x2 + x3   
POL(U11_ga(x1, x2, x3)) = 1 + 2·x1 + 2·x2 + 2·x3   
POL(U12_ga(x1, x2)) = 1 + 2·x1 + 2·x2   
POL(U13_ga(x1, x2, x3)) = 2 + 2·x1 + 2·x2 + x3   
POL(U2_GA(x1, x2)) = x1 + 2·x2   
POL(U6_GA(x1, x2)) = 2·x1 + 2·x2   
POL(U9_ga(x1, x2)) = 2 + 2·x1 + x2   
POL(hbal_treecA_in_ga(x1)) = 2 + x1   
POL(hbal_treecA_out_ga(x1, x2)) = 2 + x1 + 2·x2   
POL(nil) = 0   
POL(s(x1)) = 1 + 2·x1   
POL(t(x1, x2, x3)) = x1 + x2 + x3   
POL(x) = 0   
POL(zero) = 2   

(10) Obligation:

Q DP problem:
P is empty.
The TRS R consists of the following rules:

hbal_treecA_in_ga(zero) → hbal_treecA_out_ga(zero, nil)
hbal_treecA_in_ga(s(zero)) → hbal_treecA_out_ga(s(zero), t(x, nil, nil))
hbal_treecA_in_ga(s(s(X1))) → U9_ga(X1, hbal_treecA_in_ga(s(X1)))
hbal_treecA_in_ga(s(s(X1))) → U12_ga(X1, hbal_treecA_in_ga(X1))
U12_ga(X1, hbal_treecA_out_ga(X1, X2)) → U13_ga(X1, X2, hbal_treecA_in_ga(s(X1)))
U13_ga(X1, X2, hbal_treecA_out_ga(s(X1), X3)) → hbal_treecA_out_ga(s(s(X1)), t(x, X2, X3))
U9_ga(X1, hbal_treecA_out_ga(s(X1), X2)) → U10_ga(X1, X2, hbal_treecA_in_ga(s(X1)))
U10_ga(X1, X2, hbal_treecA_out_ga(s(X1), X3)) → hbal_treecA_out_ga(s(s(X1)), t(x, X2, X3))
U9_ga(X1, hbal_treecA_out_ga(s(X1), X2)) → U11_ga(X1, X2, hbal_treecA_in_ga(X1))
U11_ga(X1, X2, hbal_treecA_out_ga(X1, X3)) → hbal_treecA_out_ga(s(s(X1)), t(x, X2, X3))

The set Q consists of the following terms:

hbal_treecA_in_ga(x0)
U12_ga(x0, x1)
U13_ga(x0, x1, x2)
U9_ga(x0, x1)
U10_ga(x0, x1, x2)
U11_ga(x0, x1, x2)

We have to consider all (P,Q,R)-chains.

(11) PisEmptyProof (EQUIVALENT transformation)

The TRS P is empty. Hence, there is no (P,Q,R) chain.

(12) YES